package com.stars.home.adapter

import android.view.View
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.google.gson.Gson
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.home.R
import com.stars.home.activity.*
import com.stars.home.databinding.ItemBankListBinding
import com.stars.home.databinding.ItemMsgBinding
import com.stars.home.model.BackList
import com.stars.home.model.TrMsgList
import com.stars.home.model.User
import com.stars.home.vmodel.BankListVModel
import com.stars.home.vmodel.MsgVModel
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

class BankListAdapter(var vm: BankListVModel) : BAdapter<BackList, BaseDataBindingHolder<ItemBankListBinding>>(R.layout.item_bank_list) {

    override fun convert(holder: BaseDataBindingHolder<ItemBankListBinding>, item: BackList) {
        holder.dataBinding?.vm = vm
        holder.dataBinding?.item = item

        if(!item.card.isNullOrEmpty()) {
            var bankName = item.card
            var s1 = bankName?.subSequence(0, 3)
            var s2 = bankName?.subSequence(bankName.length - 4, bankName.length)
            var s = item.name + "(" + "$s1 **** $s2" + ")"
            holder.dataBinding?.tvCard?.text = s


        }

        if(null!=item.chose&&item.chose){
            holder.dataBinding?.llBg?.setBackgroundResource(R.drawable.bg_pay_on)
            holder.dataBinding?.imgBg?.visibility=View.VISIBLE
        }else{
            holder.dataBinding?.llBg?.setBackgroundResource(R.drawable.bg_pay_off)
            holder.dataBinding?.imgBg?.visibility=View.GONE
        }





    }
}
